package com.dk.controller;


import com.dk.model.Scheduld;
import com.dk.service.ScheduldService;
import com.dk.vo.CraftConstituteVO;
import com.dk.vo.CraftRelatedProductVO;
import com.dk.vo.ScheduldVO;
import com.dongdongshop.data.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 任务表 前端控制器
 * </p>
 *
 * @author wbh
 * @since 2023-03-21
 */
@RestController
@RequestMapping("scheduld")
public class ScheduldController {

    @Autowired
    private ScheduldService scheduldService;

    @GetMapping("getInfoList")
    public Result getInfoList(){
        List<ScheduldVO> infoList = scheduldService.getInfoList();
        return Result.OK().setData(infoList);
    }

    @GetMapping("getInfoScheduldByWordId")
    public Result getInfoScheduldByWordId(ScheduldVO scheduldVO) {
        List<ScheduldVO> scheduldVOList = scheduldService.getInfoScheduldByWordId(scheduldVO);
        return Result.OK().setData(scheduldVOList);
    }

    @PostMapping("insertInfoScheduld")
    public Result insertInfoScheduld(ScheduldVO scheduldVO) {
        scheduldService.insert(scheduldVO);
        return Result.OK();
    }

    @GetMapping("getInfoScheduldById")
    public Result getInfoScheduldById(String scheduldId) {
        ScheduldVO scheduldVO = scheduldService.getInfoScheduldById(scheduldId);
        return Result.OK().setData(scheduldVO);
    }

    @PutMapping("updateInfoScheduldById")
    public Result updateInfoScheduldById(ScheduldVO scheduldVO) {
        scheduldService.updateInfoScheduldById(scheduldVO);
        return Result.OK();
    }

    @DeleteMapping("deleteInfoScheduldById")
    public Result deleteInfoScheduldById(String scheduldId) {
        scheduldService.deleteInfoScheduldById(scheduldId);
        return Result.OK();
    }


    @GetMapping("getInfoCraftConstituteByMaterialId")
    public Result getInfoCraftConstituteByMaterialId(String  materialId){
        List<CraftConstituteVO> infoCraftConstituteByMaterialId = scheduldService.getInfoCraftConstituteByMaterialId(materialId);
        return Result.OK().setData(infoCraftConstituteByMaterialId);
    }

}

